package com.terrace.web.tagext.easyui;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.terrace.web.tagext.easyui.support.ComboTagSupport;

/**
 * 组合树标签
 * @author jiangyg
 *
 */
public class ComboTreeTag extends ComboTagSupport {
	
	private static final long serialVersionUID = 6755315977556070961L;
	
	/**
	 * 日志
	 */
	private static final Logger logger = LoggerFactory.getLogger(ComboTreeTag.class);

	/**
	 * 远程数据URL
	 */
	private String url;
	
	@Override
	public int doStartTag() throws JspException {
		return EVAL_PAGE;
	}

	@Override
	public int doEndTag() throws JspException {
		try {
			JspWriter out = this.pageContext.getOut();
			StringBuffer sb = new StringBuffer();
			sb.append("<select class=\"easyui-combotree\" id=\"" + name + "\" name=\"" + name + "\" data-options=\"");
			sb.append(this.assembleDataOptions());
			sb.append("url:'" + this.url + "'");
			sb.append("\"></select>");
			out.print(sb.toString());
		} catch (Exception e) {
			logger.error("组合树生成失败：", e);
		}
		return EVAL_PAGE;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

}
